
const config = require('./config/project');
export default {
  /*
  ** Nuxt rendering mode
  ** See https://nuxtjs.org/api/configuration-mode
  */
  mode: 'universal',
  render: {
    resourceHints: false
  },
  env: {
    BASE_UC_URL: '/gw/ucsapi',
    BASE_NRMS_URL: '/gw/rescenterapi/nrms',
    BASE_URL: process.env.BASE_URL,
    NODE_ENV: 'dev'
  },
  /*
  ** Nuxt target
  ** See https://nuxtjs.org/api/configuration-target
  */
  target: 'server',
  // loading: '~/components/loading/index.vue', // loading...
  server: {
    port: config.port,
    host: '0.0.0.0'
  },
  router: {
    base: '/'
  },
  /*
  ** Headers of the page
  ** See https://nuxtjs.org/api/configuration-head
  */
  head: {
    title: process.env.npm_package_name || '',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: process.env.npm_package_description || '' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ],
    script: [
      {
        src: `/rem/flexible.js`, type: 'text/javascript', charset: 'utf-8' }
    ]
  },
  /*
  ** Global CSS
  */
 css: ['@/assets/css/reset.css'],
  /*
  ** Plugins to load before mounting the App
  ** https://nuxtjs.org/guide/plugins
  */
  plugins: [
    { src: '~/plugins/vconsole.js', ssr: false },
    // { src: '~/plugins/axios.js', ssr: false },
    { src: '~/plugins/vant.js', ssr: false }
  ],
  /*
  ** Auto import components
  ** See https://nuxtjs.org/api/configuration-components
  */
  components: true,
  /*
  ** Nuxt.js dev-modules
  */
  buildModules: [
  ],
  /*
  ** Nuxt.js modules
  */
  modules: [
    '@nuxtjs/axios',
    '@nuxtjs/pwa',
    '@nuxtjs/proxy'
  ],
  axios: {
    proxy: true
  },
  proxy: {
    '/gw/ucsapi': {
      target: 'http://192.168.167.188:26681',
      changeOrigin: true,
      pathRewrite: { '^/gw/ucsapi': '/' }
    },
    '/gw/rescenterapi/nrms': {
      target: 'http://192.168.119.10:22100',
      changeOrigin: true,
      pathRewrite: { '^/gw/rescenterapi/nrms': '/' }
    }
  },
  /*
  ** Build configuration
  ** See https://nuxtjs.org/api/configuration-build/
  */
  build: {
    cssSourceMap: false,
    postcss: [
      require('postcss-px2rem')({
        remUnit: 75
      })
    ]
  },
  pwa: {
    workbox: {
      config: {
        debug: false
      },
      // offline: false,
      workboxURL: 'https://cdn.jsdelivr.net/npm/workbox-cdn/workbox/workbox-sw.js',
      cachingExtensions: '@/plugins/workbox-caching.js',
      // runtimeCaching: [
      //   {
      //     urlPattern: 'https://ubtest.yjt361.com/.*',

      // Defaults to `networkFirst` if omitted
      // handler: 'networkFirst',

      // Defaults to `GET` if omitted
      // method: 'GET'

      //     strategyOptions: {
      //       cacheName: 'our-cache',
      //       cacheExpiration: {
      //         maxEntries: 10,
      //         maxAgeSeconds: 300
      //       }
      //     }
      //   },
      //   {
      //     urlPattern: /.*(\.jsp)$/,
      //     strategyOptions: {
      //       cacheName: 'our-cache',
      //       cacheExpiration: {
      //         maxEntries: 10,
      //         maxAgeSeconds: 300
      //       }
      //     }
      //   }
      // ]
    },
    // Disable Add to Home Screen button (the mini-infobar)
    manifest: {
      display: 'browser'
    }
  }
}
